<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">

    <script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script src="/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>

<body>
    <div class="layui-form layuimini-form">
        <form action="" class="layui-form" lay-filter="residentForm">
            <input type="hidden" name="id" class="layui-input">

            <div class="layui-form-item">
                <label class="layui-form-label required">器材名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" placeholder="请输入名称"
                        value="" class="layui-input">

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">位置</label>
                <div class="layui-input-block">
                    <input type="text" name="place" lay-verify="required" lay-reqtext="位置不能为空" placeholder="请输入位置"
                        value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">数量</label>
                <div class="layui-input-block">
                    <input type="text" name="number" lay-verify="required" lay-reqtext="数量不能为空" placeholder="请输入器材数量"
                        value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">价格</label>
                <div class="layui-input-block">
                    <input type="text" name="price" lay-verify="required" lay-reqtext="价格不能为空" placeholder="请输入价格"
                        value="" class="layui-input">

                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">器材照片</label>

                <div class="layui-input-block">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test1">上传图片</button>
                        <input type="hidden" name="picture" id="pic">
                        <div class="layui-upload-list">
                            <img style="width: 100px;" class="layui-upload-img" id="demo1">
                            <p id="demoText"></p>
                        </div>
                        <div style="width: 95px;">
                            <div class="layui-progress layui-progress-big" lay-showpercent="yes" lay-filter="demo">
                                <div class="layui-progress-bar" lay-percent=""></div>
                            </div>
                        </div>
                    </div>


                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">事件备注</label>
                <div class="layui-input-block">
                    <textarea name="event" class="layui-textarea" placeholder="请输入事件信息"></textarea>
                </div>
            </div>


        </form>
    </div>
    <script>
        layui.use(['form', 'upload', 'element'], function () {
            var form = layui.form,
                layer = layui.layer,
                upload = layui.upload,
                element = layui.element,
                laydate = layui.laydate,//添加日期
                $ = layui.$;


            // 渲染日期组件
            laydate.render({
                elem: '#date'
            });

            //从localStorage 把数据取出来  赋值给表单项
            var jsonStr = localStorage.getItem("equipment");
            var stuObj = JSON.parse(jsonStr);
            console.log(stuObj)
            //给表单项赋值
            form.val("residentForm", {

                id: stuObj.id,
                name: stuObj.name,
                place: stuObj.place,
                number: stuObj.number,
                price: stuObj.price,
                picture: stuObj.picture,
                event: stuObj.event,
            
            })
            $("#demo1").attr("src", stuObj.picture);

        });
    </script>
</body>

</html>